home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / mindos11.zip / MBLOCK.C < prev    next >
C/C++ Source or Header  |  1991-03-22  |  2KB  |  76 lines

  1. /*  mblock.c    -- display a Minix disk block */
  2. /*  Copyright 1988,1991 Steven W. Harrold - All rights reserved. */
  3. /*  $Header: MBLOCK.C_V 1.4 91/03/22 07:54:07 SWH Exp $ */
  4.  
  5. #include    <stdio.h>
  6. #include    <stdlib.h>
  7. #include    <ctype.h>
  8. #include    <string.h>
  9. #include    "mfs.h"
  10. #include    "dev.h"
  11.  
  12. DEVINIT
  13. PRINT_HEX_BUF
  14. READ_BLOCK
  15.  
  16.  
  17. /*==================================================================*/
  18. main (argc, argv)
  19. int     argc ;
  20. char    *argv[] ;
  21. {
  22.     byte    buf[BLOCK_SIZE] ;
  23.     int     blkno = 0 ;
  24.     int     drive ;
  25.     char    drid = 'A' ;
  26.     char    *dp = DRIVES ;
  27.     struct devdata *ddata ;
  28.  
  29.     printf ("**** Displays a block from a Minix file system ****\n") ;
  30.     printf ("\n") ;
  31.  
  32. /*  Does he want help?
  33.  */
  34.     if ((argc >= 2) && (argv[1][0] == '-') && (argv[1][1] == '?'))
  35.     {
  36. printf ("Copyright 1988,1991 Steven W. Harrold - All rights reserved\n") ;
  37.         printf ("Version %s\n", VERSION) ;
  38.         printf ("Usage:   %s  [blkno] [drid]\n", argv[0]) ;
  39.         printf ("'blkno' is number of block [0..32767]\n") ;
  40.         printf ("'drid' is a letter from the set [a-z], default: 'a'\n") ;
  41.         exit (0) ;
  42.     }
  43.  
  44. /*  Fetch the block number
  45.  */
  46.     if (argc >= 2)
  47.         blkno = atoi(argv[1]) ;
  48.  
  49. /*  Fetch the drive identifier
  50.  */
  51.     if (argc >= 3)
  52.     {
  53.         drid = toupper(argv[2][0]) ;
  54.         if ((drid < 'A') || (drid > 'Z'))
  55.             drid = 'A' ;
  56.     }
  57.     drive = strchr (dp, drid) - dp ;
  58.     ddata = devinit (drive,0) ;
  59.     if (!ddata)
  60.     {
  61.         printf ("Cannot initialize device 0x%02X, Dstatus=%d\n",
  62.                 drive, Dstatus) ;
  63.         exit (2) ;
  64.     }
  65.  
  66. /*  The desired block
  67.  */
  68.     read_block (buf, blkno, ddata) ;
  69.     print_hex_buf (buf, blkno, "Contents of selected block") ;
  70.  
  71.  
  72. } /* main() */
  73.  
  74.  
  75. /*---eof---*/
  76.